package com.example.mymicaihu.adapter.network;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.mymicaihu.R;
import com.example.mymicaihu.bean.network.LegionBean;

import java.util.List;


/**
 * 作者：朱勇闯
 * data : 2021/4/25  17:02
 * 作用： xxxx
 */
public class LegionAdapter extends BaseAdapter<LegionBean.ArmyGroupListBean> {
    private static final String TAG = "朱勇闯LegionAdapter";
    public ItemListener itemListener;

    public void setItemListener(ItemListener itemListener) {
        this.itemListener = itemListener;
    }

    public LegionAdapter(List<LegionBean.ArmyGroupListBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, LegionBean.ArmyGroupListBean listBean, int position) {
        TextView gid = holder.getView(R.id.tv_item_network_gid_legion);
        TextView title = holder.getView(R.id.tv_item_network_title_legion);
        TextView warZone = holder.getView(R.id.tv_item_network_warZone_legion);
        TextView level = holder.getView(R.id.tv_item_network_level_legion);
        TextView description = holder.getView(R.id.tv_item_network_description_legion);
        TextView memberLimit = holder.getView(R.id.tv_item_network_memberLimit_legion);
        TextView tag1 = holder.getView(R.id.tv_item_network_tag_legion1);
        TextView tag2 = holder.getView(R.id.tv_item_network_tag_legion2);
        TextView tag3 = holder.getView(R.id.tv_item_network_tag_legion3);
        ImageView image = holder.getView(R.id.iv_item_network_legion);

        gid.setText("番号 " + listBean.getGid());
        warZone.setText(listBean.getWarZone());
        level.setText(listBean.getLevel());
        title.setText(listBean.getTitle());
        memberLimit.setText(listBean.getMember() + "/" + listBean.getMemberLimit());
        description.setText(listBean.getDescription());
        if (listBean.getTag().size() != 0 && listBean.getTag().get(0) != null) {
            tag1.setText(listBean.getTag().get(0) + " | ");
        } else if (listBean.getTag().size() != 0 && listBean.getTag().get(1) != null) {
            tag2.setText(listBean.getTag().get(1) + " | ");
        } else if (listBean.getTag().size() != 0 && listBean.getTag().get(2) != null) {
            tag3.setText((CharSequence) listBean.getTag().get(2));
        } else if (listBean.getTag().size() == 0 && listBean.getTag() == null) {
            tag1.setText(null);
        }

        Glide.with(context).load(listBean.getIcon()).into(image);
    }

    public interface ItemListener {
        void onItemClickListener(int pos);
    }

}
